package studio.servletcliente;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import studio.excepcion.DAOExcepcion;
import studio.modelo.Cliente;
import studio.negocio.SeguridadCliente;

/**
 * Servlet implementation class SerRegCliente
 */
public class SerRegCliente extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public SerRegCliente() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		SeguridadCliente neg = new SeguridadCliente();
		
		String dni  = request.getParameter("dni");
		String nombres  = request.getParameter("nombres");
		String mail  = request.getParameter("email");
		String fnac  = request.getParameter("fnac");
		String clave  = request.getParameter("clave1");
		String clave2  = request.getParameter("clave2");
		//clave2
		
		try {
			neg.insertarCliente(dni, nombres, mail, fnac, clave, 2, clave2);
			response.sendRedirect(request.getContextPath() + "/Inicio.jsp");
		} catch (DAOExcepcion e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}

}
